package com.wcsy.myblog.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wcsy.myblog.dao.UserMapper;
import com.wcsy.myblog.entity.JsonResult;
import com.wcsy.myblog.entity.User;
import com.wcsy.myblog.entity.UserInfo;
import com.wcsy.myblog.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * 用户个人资料
 */
@CrossOrigin
@RestController
@RequestMapping("userInfo")
@Api(description = "用户个人资料")
@ApiModel
public class UserInfoController {
    @Autowired
    IUserInfoService iUserInfoService;
    @Autowired
    HttpSession session;

    /**
     * 添加用户个人资料
     */
   @GetMapping("insert")
   @ApiOperation("添加用户个人资料")
    public JsonResult insert(@RequestBody UserInfo userInfo){
       try {
           iUserInfoService.insertUserInfo(userInfo);
           return new JsonResult(200,"success","");
       } catch (Exception e) {
           e.printStackTrace();
           return new JsonResult(500,"fail","");
       }
   }

    /**
     * 修改个人资料
     * @param userInfo
     * @return
     */
   @GetMapping("update")
    @ApiOperation("修改个人资料")
    public JsonResult update(@RequestBody UserInfo userInfo){
       try {
           iUserInfoService.update(userInfo);
           return new JsonResult(200,"success","");
       }catch (Exception e) {
           e.printStackTrace();
           return new JsonResult(500,"fail","");
       }
   }
}














